<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>业绩分配_对公客户</title>
</head>
<e:View id="eView">
	<script language="JScript.Encode" src="<%=request.getContextPath()%>/js/perform/fp_commonAssign.js"></script>
	
	<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;">
		<e:Dataset
			id="Dataset_Master" pageSize="-1" onAfterScroll="Dataset_Master_onAfterScroll(dataset);" datasetDefinition="DatasetDefinition_fp.dsd" datasetRef="Dataset_Master">
			<e:Field name="id" dataType="string" label="主键Id" maxLength="32" />
			 <e:Field name="resId" dataType="string" label="资源Id" maxLength="32" defaultValue="${param.custId}"/>
			 <e:Field name="resOrgId" dataType="string" label="资源所在机构" maxLength="32" defaultValue="${param.orgId}"/>
			 <e:Field name="fitOrgId" dataType="string" label="适用机构号" maxLength="32" dropDown="DropDown_Org"/>
			 <e:Field name="fitProductId" dataType="string" label="适用产品" maxLength="20" required="true" dropDown="ListDropDown_ALLOCATE_CUSTBUSTYPE" />
			 <e:Field name="startDate" dataType="date" label="开始日期" maxLength="10" required="true"/>
			 <e:Field name="endDate" dataType="date" label="结束日期" maxLength="10" required="true" defaultValue="2999-12-31"/>
			 <e:Field name="remark" dataType="string" label="备注" maxLength="32" />
		</e:Dataset> 
		<e:Dataset id="Dataset_Detail" pageSize="-1" datasetDefinition="DatasetDefinition_fp.dsd" datasetRef="Dataset_Detail">
			<e:Field name="id" dataType="string" label="主键Id" maxLength="32" />
			 <e:Field name="fkId" dataType="string" label="分配主表Id" maxLength="32" />
			 <e:Field name="belongUserId" dataType="string" label="分配对象" maxLength="32" dropDown="LookupDropDown_User" required="true"/>
			 <e:Field name="belongOrgId" dataType="string" label="分配对象机构" maxLength="32" />
			 <e:Field name="rate" dataType="bigdecimal" label="分配比例" maxLength="6" required="true"/>
			 <e:Field name="belongUserName" dataType="string" label="分配对象" maxLength="32" />
			 <e:Field name="belongOrgName" dataType="string" label="分配对象机构" maxLength="32" />
			 <e:Field name="createTime" dataType="date" label="创建时间" maxLength="7" readOnly="true"/>
			 <e:Field name="createUserId" dataType="string" label="创建人ID" maxLength="32" visible="false"/>
			 <e:Field name="createUserName" dataType="string" label="创建人名称" maxLength="100" readOnly="true"/>
			 <e:Field name="createOrgId" dataType="string" label="创建机构ID" maxLength="32" visible="false"/>
			 <e:Field name="createOrgName" dataType="string" label="创建机构名称" maxLength="100" readOnly="true"/>
			 <e:Field name="orgLevelCode" dataType="string" label="机构级次" maxLength="100" readOnly="true"/>
			 <e:Field name="updateUserId" dataType="string" label="修改人ID" maxLength="32" readOnly="true"/>
			 <e:Field name="updateUserName" dataType="string" label="修改人" maxLength="100" readOnly="true"/>
			 <e:Field name="updateTime" dataType="date" label="修改时间" maxLength="7" readOnly="true"/>
		</e:Dataset> 
		
		<e:Dataset id="Dataset_Org" pageSize="-1">
			<e:Field name="CODE" dataType="string" />
			<e:Field name="NAME" dataType="string" />
		</e:Dataset> 
		
		<e:DataDropDown id="DropDown_Org" dataset="Dataset_Org" visibleFields="NAME" codeField="CODE" textField="NAME" showColumnHeader="false" fixed="true">
		</e:DataDropDown>
		
		<e:ListDropDown id="ListDropDown_ALLOCATE_CUSTBUSTYPE" fixed="true">
			<e:ListDropDownItem name="ListDropDownItem1" label="全部" value="-1"></e:ListDropDownItem>
			<e:ListDropDownItem name="ListDropDownItem2" label="存款" value="100"></e:ListDropDownItem>
			<e:ListDropDownItem name="ListDropDownItem3" label="贷款" value="200"></e:ListDropDownItem>
			<e:ListDropDownItem name="ListDropDownItem4" label="中间业务" value="500"></e:ListDropDownItem>
		</e:ListDropDown>
		
		<e:DatePicker id="DatePicker1" fixed="true" /> 
		
		<e:Command id="CommandSaveDetail" 	action="com.longtop.perform.ar.web.ArDsCustAssignAction" method="saveMasterDetail" submitForm="true" submitFormScope="input-text"
			showHintInfoOnSuccess="false">
			<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_Detail"  submitType="all" />
			<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_Master"  submitType="all" />
		</e:Command> 
		
		<e:Command id="CommandGetDetail" action="com.longtop.perform.ar.web.ArDsCustAssignAction" method="getDetail" showHintInfoOnSuccess="false">
			<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_Detail" alwayRefreshClient="true" submitType="none"/>
			<e:Parameter name="fkId" dataType="string" />
		</e:Command>
		
		<e:LookupDropDown id="LookupDropDown_User" path="/jsp/framework/sys/user/userDropdown.jsp"	windowWidth="650" windowHeight="450" 
					autoDropDown="true" fixed="true" onSelect="LookupDropDown_User_onSelect(dropdown,iframe,text)" windowCaption="选择员工">
		</e:LookupDropDown>
		
	</div>

	<e:Page id="ePage" action="com.longtop.perform.ar.web.ArDsCustAssignAction" style="width:100%;height:350px" onAfterLoadPage="ePage_onAfterLoadPage()">
		<body>
		<table width="100%" height="100%">
			<tr height="50px">
				<td> 
					<e:GroupBox id="group_Info" caption="客户信息" style="width:100%;height:100%">
						<table width="100%" border="0">
							<tr>
								<td align="right">客户号 :</td>
								<td align="left"><e:Text id="T_custNo" style="width: 150px;" value="${param.custId}" readOnly="true"/></td>
								<td align="right">客户名称 :</td>
								<td align="left" ><e:Text id="T_custName" style="width: 150px;" readOnly="true"/></td>																								
								</tr>
							<tr>
								<td align="right">所属机构号 :</td>
								<td align="left" ><e:Text id="T_blong" style="width: 150px;" value="${param.orgId}" readOnly="true"/></td>
								<td align="right">所属机构名称 :</td>
								<td align="left" colspan="1"><e:Text id="T_orgName" style="width: 150px;" readOnly="true"/></td>																									
							</tr>	
						 </table>					
					</e:GroupBox>
				</td>
			</tr>
			<tr>
				<td valign="top" style="width: 100% height :   100%" align="left">
				<e:GroupBox id="group_allocate" caption="已分配情况" style="width:100%;height:100%">
					<table width="100%">
						<tr>
							<td align="right">
								<e:RecordNavigator id="RecordNavigator_CustAssign" dataset="Dataset_Master" showNavigatorButton="false">
										<e:RecordButton id="RecordButton_insert" label="新增" onClick="addMaster()" icon="/images/add.gif"></e:RecordButton>
										<e:RecordButton id="RecordButton_delete" label="删除" onClick="delMaster()" icon="/images/delete.gif"></e:RecordButton>
								</e:RecordNavigator>
							</td>
						</tr>
						<tr>
							<td>
								<e:Grid id="grid_allocate" dataset="Dataset_Master" onClick="Grid_Master_onClick()" style="width:100%;height:160px;" showIndex="true"  showIndicator="false">
									<e:Column name="fitOrgId" field="fitOrgId" label="适用机构" style="width:25%" />
									<e:Column name="fitProductId" field="fitProductId" label="适用产品" style="width:15%"/>
									<e:Column name="startDate" field="startDate" label="开始日期" style="width:15%"  />
									<e:Column name="endDate" field="endDate" label="结束日期" style="width:15%"  />
									<e:Column name="remark" field="remark" label="备注" style="width:30%"  />
								</e:Grid>
							</td>
						</tr>
					</table>
				</e:GroupBox>
				</td>
			</tr>
			<tr>
				<td valign="top" style="width: 100% height :   100%" align="left">
				<e:GroupBox id="group_allocate2" caption="分配详情" style="width:100%;height:100%">
					<table width="100%">
						<tr>
							<td align="right">
								<e:RecordNavigator id="RecordNavigator_CustAssignDetail" dataset="Dataset_Detail" showNavigatorButton="false">
										<e:RecordButton id="RecordButton_insert" label="新增" onClick="addDetail()" icon="/images/add.gif"></e:RecordButton>
										<e:RecordButton id="RecordButton_delete" label="删除" onClick="deleteRecord" icon="/images/delete.gif"></e:RecordButton>
								</e:RecordNavigator>
							</td>
						</tr>
						<tr>
							<td>
								<e:Grid id="grid_allocate2" dataset="Dataset_Detail" style="width:100%;height:160px;" showIndex="true" showIndicator="false">
									<e:Column name="belongUserId" field="belongUserId" label="员工号" style="width:20%" />
									<e:Column name="belongUserName" field="belongUserName" label="员工名" style="width:25%" readOnly="true" />
									<e:Column name="belongOrgName" label="所属机构" field="belongOrgName" style="width:35%" readOnly="true"></e:Column>
									<e:Column name="rate" field="rate" label="分配比率(%)" style="width:20%" />
								</e:Grid>
							</td>
						</tr>
						<tr>
							<td align="center">
								<e:Button id="Button_save" caption="保 存" style="height: 20px; width: 80px" icon="/images/save.gif" onClick="saveAllocate();" />&nbsp;&nbsp;
								<e:Button id="Button_cancel" caption="取消" style="height: 20px; width: 80px; display:none" onClick="Button_cancel_onClick()"></e:Button>
							</td>
						</tr>
					</table>
				</e:GroupBox></td>
			</tr>
		</table>
		</body>
	</e:Page>
</e:View>

<script type="text/javascript">
	var allowSearch = false;
	
	function ePage_onAfterLoadPage(){		
		var task = "${param.task}";
		if(task == "view"){
			$J("RecordNavigator_CustAssign").setEnabled(false);
			$J("RecordNavigator_CustAssignDetail").setEnabled(false);
			$J("Button_save").setVisible(false);
			$J("Dataset_Master").setReadOnly(true);
			$J("Dataset_Detail").setReadOnly(true);
		}
		
		$J("T_custName").setValue(Util.decode("${param.custName}"));
		$J("T_orgName").setValue(Util.decode("${param.orgName}"));
		allowSearch = true;
		$J("Dataset_Master").onAfterScroll();
	}
	
	//查询分配详情
	function Dataset_Master_onAfterScroll(dataset){
		if(!allowSearch || !dataset) 
			return;
					
		if(dataset.getValue("id")==null || dataset.getValue("id")==""){
			$J("Button_save").setEnabled(true);
			$J('Dataset_Detail').clearData();
			return;
		}
		$J("CommandGetDetail").parameters.setValue("fkId",dataset.getValue("id"));
		$J("CommandGetDetail").execute();
	}
</script>
</html>
